

#filePath形参:String，表示txt或csv文件的路径！例如："C:/A/1.csv" "C:/A/1.csv"
def readTxtOrCsv(filePath):
    temp=[]
    fp=open(filePath,mode="r",encoding="utf-8")
    for line in fp:
        line=line.strip()
        temp.append(line)
    fp.close()


    headers=temp[0].split(",")
    values=[]
    for i in range(len(temp)):
        if i>=1:
            values.append(temp[i])


    ret = []
    for x in values:
        data={}
        temp1=x.split(",")
        for y in range(len(headers)):
            k=headers[y]
            v=temp1[y]
            data[k]=v
        ret.append(data)
    return ret




